package com.qzimp.fujiancuo.mapper;

import com.qzimp.fujiancuo.entity.Temple;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TempleMapper {

    @Select("SELECT * FROM tb_temple WHERE id = #{id}")
    Temple findById(Long id);

    @Select("SELECT * FROM tb_temple")
    List<Temple> findAll();

    @Insert("INSERT INTO tb_temple(name, location, established_year) VALUES(#{name}, #{location}, #{establishedYear})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Temple temple);

    @Update("UPDATE tb_temple SET name = #{name}, location = #{location}, established_year = #{establishedYear} WHERE id = #{id}")
    void update(Temple temple);

    @Delete("DELETE FROM tb_temple WHERE id = #{id}")
    void delete(Long id);
}